package com.example.clicker;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.widget.Button;
import android.widget.EditText;

public class TimecodeDialogs extends Activity {

	
	public static final int IDD_ABOUT = 1; // Идентификаторы диалоговых окон
    public static final int IDD_SETTINGS = 2;
    public static final int IDD_RATE = 3;
	private static final int REQUEST_LOAD = 0;
	private static final int REQUEST_SAVE = 0;
	
    static Button btn,iabtn,inbtn,ipbtn;
    static EditText et;
   //private static android.view.View.OnClickListener myClick;
    
    public static AlertDialog getDialog(Activity activity, int ID) {
        AlertDialog.Builder builder = new AlertDialog.Builder(activity);

        switch(ID) {
        
        case IDD_SETTINGS: // Диалог настроек
        	
            View mDialog = activity.getLayoutInflater().inflate(R.layout.dialogs, null); // Получаем layout по его ID
            btn= (Button) mDialog.findViewById(R.id.CustomButton);
            et= (EditText) mDialog.findViewById(R.id.EditTextButton);
            
            builder.setView(mDialog);
            builder.setTitle(R.string.NameDialog);
            et.setOnFocusChangeListener(new OnFocusChangeListener() {          

                public void onFocusChange(View v, boolean hasFocus) {
                    if (!hasFocus) {
                    	if(btn!=null)
            				btn.setText(((EditText)v).getText().toString());
                    }
                }
            });
            iabtn= (Button) mDialog.findViewById(R.id.ButtonImageActive);
            inbtn= (Button) mDialog.findViewById(R.id.ButtonImageNormal);
            ipbtn= (Button) mDialog.findViewById(R.id.ButtonImagePressed);
         //  android.view.View.OnClickListener onClick;
			// адаптер
      /*      OnClickListener oclBtnOk = new OnClickListener() {
               	@Override
				public void onClick(DialogInterface dialog, int which) {
					// TODO Auto-generated method stub
					
				};
              };
			iabtn.setOnClickListener(myClick);
			*/
            builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { // Кнопка ОК
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            });
            builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { // Кнопка Отмена 
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
  
             builder.setCancelable(true);
            return builder.create();
        default:
            return null;
        }	
        
        	
    }

	
	public void onClick(View v) {
		// TODO Auto-generated method stub
		Intent intent = new Intent(getBaseContext(), FileDialog.class);
        intent.putExtra(FileDialog.START_PATH, "/sdcard");
        
        //can user select directories or not
        //intent.putExtra(FileDialog.CAN_SELECT_DIR, true);
        
        // alternatively you can set file filter
        intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "png" });
        
        startActivityForResult(intent, REQUEST_SAVE);
	
	}

    
}